<?php

/**
 * 文件注释
 *
 * Author: Liam
 * Datetime: 01/09/2018 00:00 PM
 */

namespace ApiBundle\Controller;

use BaseBundle\Controller\BaseController;
use Symfony\Component\HttpFoundation\Request;

class PostController extends BaseController
{
    public function postOperaAction(Request $request)
    {
        $class = $request->get('class');
        $class_name = $request->get('class_name');
        $title = $request->get('title');
        $content = $request->get('content');
        $created_at = date('y-m-d h:i:s',time());

        $post_data = array(
            'article_classify_id' => $class,
            'title' => $title,
            'article_classify_name' => $class_name,
            'content ' => $content,
            'created_at' => $created_at
        );

        $conn = $this->get('database_connection');
        $result = $conn->insert('article', $post_data);

        if($result) {
            return $this->jsonResponse('发布成功', 0);
        } else {
            return $this->jsonResponse('发布失败'.$result, 1);
        }

    }
}